<template>
  <div class="search">
    <div class="search-top">
      <h4 class="search-text">搜索</h4>
      <span @click="goOut"><van-icon name="cross"/></span>
    </div>
    <van-search
      shape="round"
      v-model="value"
      placeholder="你想去哪儿?"
      style="border-radius: 20px"
    />
    <div>
      <div class="text">
        <p class="text-l">搜索历史</p>
        <p class="text-r">删除全部</p>
      </div>
      <van-grid>
        <van-grid-item v-for="item in loadProductCategories" :key="item.id">
          <img :src="item.coverImage | dalImg" alt="" />
          <p>{{ item.name }}</p>
          <p>{{ item.desc }}</p>
        </van-grid-item>
      </van-grid>
    </div>
  </div>
</template>

<script>
  import {
  loadProductCategoriesApi,
} from "../services/products";
export default {
  name: "Search",
  data() {
    return {
      loadProductCategories: [],
    };
  },
  created(){
    this.loadData()
  },
  methods:{
    async loadData() {
      const res = await loadProductCategoriesApi();
      this.loadProductCategories = res.data;
    },
    goOut(){
      this.$router.go(-1)
    }
  }
};
</script>

<style scoped>
.van-search {
  margin-top: 3rem;
}
.search-top {
  height: 4rem;
  width: 100%;
}
.search-text {
  font-size: 1.4rem;
  line-height: 4rem;
  text-align: center;
}
.search-top span {
  position: absolute;
  top: 1rem;
  right: 1rem;
  color: rgb(212, 208, 208);
  font-size: 1.4rem;
}
.text{
  height: 4rem;
  margin: 0 1rem;
  font-size: .9rem;
}
.text-l{
  float: left;
  line-height: 4rem;
}
.text-r{
  float: right;
  color: #13c2c2;
  line-height: 4rem;
}
</style>
